package com.gitee.wsl.struct.grammar.ast.node

import com.gitee.wsl.struct.grammar.ast.node.ASTNode


open class CompositeNode(
    type: NodeType,
    final override val children: List<ASTNode>
) : Node(
    type,
    children.firstOrNull()?.startOffset ?: 0,
    children.lastOrNull()?.endOffset ?: 0
) {

    init {
        for (child in children) {
            if (child is Node) {
                @Suppress("LeakingThis")
                child.parent = this
            }
        }
    }
}